<?php
if(preg_match("/lottou/", $_SERVER["DOCUMENT_ROOT"])){
	include_once($_SERVER["DOCUMENT_ROOT"]."/config.inc.php");
	include_once($_SERVER["DOCUMENT_ROOT"]."/db.inc.php");
	$strWeb = trim($_data["Web"]);
}else{
	$_SERVER["DOCUMENT_ROOT"] = "/home/share/www/SourceSite-utf8/secure";
	include_once("/home/share/www/SourceSite-utf8/secure/config.inc.php");
	$strWeb = trim($_data["Web"]);
	include("/home/share/www/".$strWeb."/secure/db.inc.php");
}
$strUserAcc = trim($_data["Acc"]);
$strUserPwd = trim($_data["Pwd"]);
$strType = trim($_data["Type"]);


function outPutXML($strAcc, $strGroup, $strStatus){
	header("Content-Type: text/xml");
	print "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n";
	print "<MRoot>\n";
	print "\t<Acc>".$strAcc."</Acc>\n";
	print "\t<Group>".$strGroup."</Group>\n";
	print "\t<Status>".$strStatus."</Status>\n";
	print "</MRoot>";
	exit();
}

$strSQL = "select * from `bet_Member` where Account = '".$strUserAcc."' limit 0,1";
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	outPutXML($strUserAcc, 0, "Find User Data Error");
}

//找不到帳號密碼
if(PMA_mysql_num_rows($RS) == 0){
	outPutXML($strUserAcc, 0, "No User Data");
}

$objMember = PMA_mysql_fetch_object($RS);

$strCheckData = "";//$objMember -> SkypeAcc;
switch(strtolower($strType)){
	case "email":
		$strCheckData = $objMember -> Email;
		break;

	case "qq":
		$strCheckData = $objMember -> QQNum;
		break;

	case "msn":
		$strCheckData = $objMember -> MSN;
		break;

	case "skype":
	default:
		$strType = "Skype";
		$strCheckData = $objMember -> SkypeAcc;
		break;
}

if($strCheckData !== $strUserPwd){
	outPutXML($strUserAcc, 0, $strType." Error(".$strUserPwd.")");
}

$strSQL = "select GroupName_1 as GName from `bet_MemberGroup` where ID = ".$objMember -> MemberGroup;
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	outPutXML($strUserAcc, 0, "Find Group Data Error");
}
if(PMA_mysql_num_rows($RS) == 0){
	$strGroup = "No Group";
}else{
	$objGroup = PMA_mysql_fetch_object($RS);
	$strGroup = $objGroup -> GName;
	$strGroup .= $objMember -> SpGroup == 1?" ( VIP )":" ( 一般 )";
}

$strStatus = "OK";
switch($objMember -> isLock){
	case 1:
		$strStatus = "停用中";
		break;

	case 2:
		$strStatus = "停押中";
		break;
}
outPutXML($strUserAcc, $strGroup, $strStatus);
?>